package com.jvyou.app.ds.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jvyou.app.ds.domain.entity.Question;
import com.jvyou.app.ds.domain.entity.QuestionOption;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 驾校题目表(Question)表数据库访问层
 *
 * @author 橘柚
 * @since 2025-04-20 20:55:04
 */
public interface QuestionMapper extends BaseMapper<Question> {

    @Select("SELECT * FROM ds_question_option WHERE question_id = #{questionId}")
    List<QuestionOption> getOptions(@Param("questionId") Long questionId);

    Question getNextErrorQuestion();

    @Select("SELECT * FROM ds_question WHERE type_id = #{typeId} ORDER BY RAND() LIMIT 1")
    Question getRandomQuestionByType(Long typeId);
}
